package com.iknow;

import com.iknow.data.SubscribeTag;
import com.iknow.http.Response;
import com.iknow.http.ResponseException;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class TagResponse extends IKnowResponse
{
  private static final long serialVersionUID = 852394753L;
  private List<String> childList = null;
  private String mID;
  private boolean mSystemLable;
  private String mlableText;

  public TagResponse(Response paramResponse)
    throws JSONException
  {
    try
    {
      init(paramResponse.asJSONArray().getJSONObject(0));
      return;
    }
    catch (ResponseException localResponseException)
    {
      localResponseException.printStackTrace();
    }
  }

  public TagResponse(JSONObject paramJSONObject)
    throws JSONException
  {
    init(paramJSONObject);
  }

  public static List<SubscribeTag> getSubscribeTag(Response paramResponse)
    throws JSONException
  {
    ArrayList localArrayList1;
    JSONArray localJSONArray;
    try
    {
      localJSONArray = paramResponse.asJSONArray();
      ArrayList localArrayList2 = new ArrayList(localJSONArray.length());
      int i = 0;
      if (i >= localJSONArray.length())
      {
        localArrayList1 = localArrayList2;
      }
      else
      {
        localArrayList2.add(new SubscribeTag(new TagResponse(localJSONArray.getJSONObject(i))));
        ++i;
      }
    }
    catch (ResponseException localResponseException)
    {
      localResponseException.printStackTrace();
      localArrayList1 = null;
      return localArrayList1;
    }
  }

  private void init(JSONObject paramJSONObject)
    throws JSONException
  {
    JSONArray localJSONArray;
    int i;
    this.mlableText = paramJSONObject.getString("name");
    if (paramJSONObject.has("tags"))
    {
      localJSONArray = paramJSONObject.getJSONArray("tags");
      this.childList = new ArrayList();
      i = 0;
    }
    while (true)
    {
      if (i >= localJSONArray.length())
        return;
      JSONObject localJSONObject = (JSONObject)localJSONArray.get(i);
      this.childList.add(localJSONObject.getString("name"));
      ++i;
    }
  }

  public List<String> getChildList()
  {
    return this.childList;
  }

  public String getLableText()
  {
    return this.mlableText;
  }

  public boolean isSystemLable()
  {
    return this.mSystemLable;
  }
}